with ($ns("fp.utils"))
{
    fp.utils.DateTimeUtilClass = function()
    {
        var me = this;
        
        me.getDateTimeString = function(p_dateTime)
        {
            if (typeof(p_dateTime) == "string")
            {
                var date = new Date(p_dateTime * 1)
                p_dateTime = date;
            }

            var time = $format(p_dateTime, "HH:mm");
            if ($mx.locale == "zh_CN")
            {
                return $format(p_dateTime, "yyyy年M月d日 ") + time;
            }
            else
            {
                return p_dateTime.toLocaleDateString() + " at " + time;
            }
        };
        
        
        me.getShortDateTimeString = function(p_dateTime)
        {
            if (typeof(p_dateTime) == "string")
            {
                var date = new Date(p_dateTime * 1)
                p_dateTime = date;
            }
            
            var result = null;
            var now = new Date();
            var deltaMin = Math.round((now.getTime() - p_dateTime) / 1000 / 60);
            if (deltaMin <= 1)
            {
                result = $msg("fp", "MINUTE_AGO");
            }
            else if (deltaMin < 60)
            {
                result = $msg("fp", "MINUTES_AGO", [ deltaMin ]);
            }
            else if (deltaMin == 60)
            {
                result = $msg("fp", "HOUR_AGO");
            }
            else
            {
                var deltaHour = Math.round(deltaMin / 60);
                if (deltaHour < 24)
                {
                    result = $msg("fp", "HOURS_AGO", [ deltaHour ]);
                }
                else if (deltaHour == 24)
                {
                    result = $msg("fp", "DAY_AGO");
                }
                else
                {
                    var deltaDay = Math.round(deltaHour / 24);
                    if (deltaDay < 8)
                    {
                        result = $msg("fp", "DAYS_AGO", [ deltaDay ]);
                    }
                }
            }
            
            if (result == null)
            {
                if ($mx.locale == "zh_CN")
                {
                    result = $format(p_dateTime, "yyyy年M月d日");
                }
                else
                {
                    result = "yyyy-M-d";
                }
            }
            
            return result;
        }
        
        
        return me;
    };
    
    fp.utils.DateTimeUtil = new fp.utils.DateTimeUtilClass();
}